package ig.util;

import ig.ejb.metrica.da.session.editor.dto.TablaDTO;
import java.awt.Component;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.table.TableCellRenderer;
import javax.swing.JTable;

/**
 */
public class RenderTablaDTO extends JLabel implements TableCellRenderer {

    //ValueDocument vd= new ValueDocument("DOUBLE");
    JTable table=null;
    public RenderTablaDTO(JTable table) {
        this.table=table;
        //table.getColumnModel().getColumn(0).getHeaderRenderer().
        //table.getColu
        setOpaque(true);
    }

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        RenderTablaDTO etiqueta = new RenderTablaDTO(table);
        etiqueta.setFont(new java.awt.Font(Font.DIALOG, Font.BOLD, 10));
        etiqueta.setText(value.toString());
        //etiqueta.setSize(100, 200);
        etiqueta.setBackground(Color.WHITE);

        TablaDTO dTO = ( TablaDTO )value;
        if(dTO.getColumnas().size()>0){
            etiqueta.setForeground(Color.BLACK);
            etiqueta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ig/util/images/ok.png")));
        }else{
            etiqueta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ig/util/images/clear.png")));
            etiqueta.setForeground(Color.GRAY);
        }
        if (isSelected) {
            etiqueta.setBackground(table.getSelectionBackground());
            etiqueta.setForeground(table.getSelectionForeground());
        }
        return etiqueta;
    }
}